package com.info.zhiduoduo.pay.controller;

import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.utils.IPUtil;
import com.info.zhiduoduo.pay.formbean.wxpay.WXPayFromBean;
import com.info.zhiduoduo.pay.service.WeChatPayService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/wxpay")
public class WeChatPayController {

    @Autowired
    private WeChatPayService weChatPayService;

    @RequestMapping("/pay")
    @ResponseBody
    public SmartResult weChatPay(@RequestBody WXPayFromBean formBean, HttpServletRequest request){
        return weChatPayService.weChatPay(formBean, IPUtil.getIpAddr(request));
    }

    @RequestMapping("/notify")
    @ResponseBody
    public String notify(HttpServletRequest request){
       return weChatPayService.notifyPayResult(request);
    }


}
